import { Role } from '../models/role'

class CommonService {
  async dictionary() {
    const roles = await Role.find()
    const roleData = roles.map((item) => {
      return {
        label: item.name,
        value: item.code
      }
    })

    return {
      gender: {
        data: [
          { label: '未知', value: 0 },
          { label: '男', value: 1 },
          { label: '女', value: 2 }
        ],
        description: '性别信息'
      },
      user_status: {
        data: [
          { label: '禁用', value: 0 },
          { label: '正常', value: 1 }
        ],
        description: '用户状态信息'
      },
      role: {
        data: roleData,
        description: '角色信息'
      },
      article_status: {
        data: [
          { label: '未发布', value: 0 },
          { label: '已发布', value: 1 }
        ],
        description: '文章状态信息'
      }
    }
  }
}

export default new CommonService()
